package Java常用工具API.Object类.Object类一般使用;

public class Test {

    public static void main(String[] args) {
        //创建Object类对象
        Object obj1=new Object();
        Object obj2=new Object();

        //测试调用int hashCode()函数
        int h1=obj1.hashCode();
        int h2=obj2.hashCode();
        System.out.println(h1);//输出obj1哈希码值
        System.out.println(h2);//输出obj2哈希码值
        System.out.println(obj2.hashCode());
        System.out.println("--------------------");

        //测试调用class<?> getClass()方法
        Class c1=obj1.getClass();
        Class c2=obj1.getClass();//定义一个类类型变量c2
        System.out.println(obj1.getClass());
        System.out.println(obj2.getClass());
        System.out.println("--------------------");
        System.out.println(c1);
        System.out.println(c2);
        System.out.println("--------------------");


        //测试调用String toString()方法
        String s1=obj1.toString();
        String s2=obj2.toString();
        System.out.println(s1);
        System.out.println(s2);
        System.out.println("--------------------");
        System.out.println(obj1);
        System.out.println(obj2);
        System.out.println("--------------------");

        //测试调用boolean equals()方法

        boolean b1=obj1.equals(obj2);
        boolean b2=obj2.equals(obj1);
        System.out.println(b1);
        System.out.println(b2);



    }
}
